package com.ckh.springboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ckh.springboot.common.Result;
import com.ckh.springboot.entity.QuestionBank;
import com.ckh.springboot.service.IQuestionBankService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/questionBank")
// @CrossOrigin(origins = "http://localhost:9528")
public class QuestionBankController {

    @Resource
    private IQuestionBankService questionBankService;

    @GetMapping("/list")
    public Result list() {
        List<QuestionBank> list = questionBankService.list();
        return Result.success(list);
    }

    @PostMapping("/create")
    public Result create(@RequestBody QuestionBank questionBank) {
        questionBankService.save(questionBank);
        return Result.success();
    }

    @PostMapping("/update")
    public Result update(@RequestBody QuestionBank questionBank) {
        questionBankService.updateById(questionBank);
        return Result.success();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        questionBankService.removeById(id);
        return Result.success();
    }
}